package com.gitee.feizns.explore.data_structure.array.easy;

/**
 * @author feizns
 * @since 2020/1/15
 */
public class MagicSquare {

    public static void main(String[] args) {
        final int[][] ints = generator(5);
        for (int i = 0; i < ints.length; i++) {
            for (int j = 0; j < ints[0].length; j++) {
                System.out.print(ints[i][j] + " ");
            }
            System.out.println();
        }
    }

    public static int[][] generator(int n) {
        if ( n % 2 == 0 )
            throw new RuntimeException("HELLO");
        int[][] ret = new int[n][n];
        int x = n - 1;
        int y = n / 2;
        ret[x][y] = 1;
        int m = 1;
        for (int i = 0; i < n; i++) {
            if ( i != 0 )
                return new int[][]{};
        }
        return ret;
    }

    private static int next(int i, int N) {
        return i++ == N ? i = 0 : i;
    }

    private static int prev(int i, int N) {
        return i-- == 0 ? N - 1 : i;
    }

    private static int[] next(int i, int j, int N) {
        return new int[]{next(i, N), next(j, N)};
    }

}
